package com.salesmanager.core.business.customer.model;

import com.salesmanager.core.business.common.model.audit.AuditSection;
import com.salesmanager.core.business.generic.model.SalesManagerEntity;
import com.salesmanager.core.constants.SchemaConstant;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;


@Entity
@Table(name = "CUSTOMER_ACCOUNT")
public class CustomerAccount extends SalesManagerEntity<Long, CustomerAccount> {
	private static final long serialVersionUID = -6966934116557219193L;

    @Id
    @Column(name = "CUSTOMER_ID", unique=true, nullable=false)
    @GenericGenerator(name="pkGenerator", strategy="foreign", parameters=@org.hibernate.annotations.Parameter(name = "property" ,value = "customer"))
    @GeneratedValue(generator="pkGenerator", strategy=GenerationType.IDENTITY)
    private Long id;

    @OneToOne(mappedBy = "customerAccount", cascade = { CascadeType.PERSIST,
            CascadeType.MERGE, CascadeType.REFRESH } ,optional = false)
    @PrimaryKeyJoinColumn
    private Customer customer;

	@Column(name = "BALANCE")
	private BigDecimal balance; //余额

    @Column(name = "GOLD")
    private BigDecimal gold;//金币

	@Column(name = "INTEGRAL")
	private Integer integral; //积分

    @Column(name = "LEVEL")
    private Integer level;//等级

	@Column(name = "FROZEN")
	private Boolean frozen; //冻结
	
	@Embedded
	private AuditSection auditSection = new AuditSection();

	@Override
	public Long getId() {
		return this.id;
	}

	@Override
	public void setId(Long id) {
		this.id = id;
	}

    public BigDecimal getBalance() {
        return balance;
    }

    public void setBalance(BigDecimal balance) {
        this.balance = balance;
    }

    public Integer getIntegral() {
        return integral;
    }

    public void setIntegral(Integer integral) {
        this.integral = integral;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public Boolean getFrozen() {
        return frozen;
    }

    public void setFrozen(Boolean frozen) {
        this.frozen = frozen;
    }

    public AuditSection getAuditSection() {
        return auditSection;
    }

    public void setAuditSection(AuditSection auditSection) {
        this.auditSection = auditSection;
    }

    public BigDecimal getGold() {
        return gold;
    }

    public void setGold(BigDecimal gold) {
        this.gold = gold;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

}
